package com.ksyun.campus.metaserver.util;

import cn.hutool.http.HttpRequest;

import java.util.Map;

/**
 * http远程调用工具类
 */
public class HttpRemoteUtil {
    /**
     * http请求前缀
     */
    private static final String REQUEST_PREFIX = "http://";

    /**
     * 返回自定义post请求路径的HttpRequest工具
     *
     * @param host 请求ip+port
     * @param path 请求路径
     * @return HttpRequest工具对象
     */
    public static HttpRequest post(String host, String path) {
        return HttpRequest.post(REQUEST_PREFIX + host + path);
    }

    /**
     * 返回自定义get请求路径的HttpRequest工具
     *
     * @param host 请求ip+port
     * @param path 请求路径
     * @param params 请求参数map
     * @return HttpRequest工具对象
     */
    public static HttpRequest get(String host, String path, Map<String, Object> params) {
        return HttpRequest.get(REQUEST_PREFIX + host + path).form(params);
    }
}

